Skip to content

HTML5 parser optimizations #13702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Conversation

nielsdos
Copy link
Member

A patch series to optimize HTML5 parsing. See individual commits.

Tested on English Wikipedia homepage.
Test code:

<?php
$contents = file_get_contents('wiki.html');
for ($i=0;$i<500;$i++)
  $dom = @DOM\HTMLDocument::createFromString($contents);
Benchmark 1: ./sapi/cli/php test.php
  Time (mean ± σ):     779.4 ms ±   4.9 ms    [User: 774.0 ms, System: 4.0 ms]
  Range (min … max):   772.7 ms … 791.3 ms    10 runs
 
Benchmark 2: ./sapi/cli/php_old test.php
  Time (mean ± σ):     859.0 ms ±   8.5 ms    [User: 854.2 ms, System: 3.4 ms]
  Range (min … max):   852.1 ms … 878.7 ms    10 runs
 
Summary
  ./sapi/cli/php test.php ran
    1.10 ± 0.01 times faster than ./sapi/cli/php_old test.php

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks correct to me

@nielsdos nielsdos closed this in b955973 Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants